<template>
  <div class="info">
    <el-avatar
      class="info-avatar"
      :size="50"
      shape="square"
      cross-origin
      :src="info[logo] ? formatUrl(info[logo]) : profilePhoto"
    />
    <div class="info-detail">
      <div class="info-detail-top">
        <div v-if="info.name" class="name">{{ info.name }}</div>
        <div v-if="info.title" class="title">{{ info.title }}</div>
      </div>
      <div class="info-detail-bottom">
        <div v-if="info.email" class="logincode">{{ info.email }}</div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { defineProps } from 'vue'

import profilePhoto from '@/assets/profile-photo.jpg'

import { formatUrl } from '@/utils/common/formatUrl'

defineProps({
  info: {
    type: Object,
    default: () => {},
  },
  logo: {
    type: String,
    default: 'headIcon',
  },
})
</script>

<style lang="scss" scoped>
.info {
  display: flex;
  align-items: center;
  // padding: 5px;

  &-avatar {
    margin-right: 10px;
    flex-shrink: 0;
    background: transparent;
  }

  &-detail {
    &-top {
      display: flex;
      align-items: center;
      // height: 30px;
      line-height: 30px;

      .name {
        margin-right: 8px;
        font-size: 16px;
        font-weight: 600;
      }

      .title {
        // height: 20px;
        padding: 0 8px;
        font-size: 12px;
        line-height: 20px;
        color: #fff;
        word-break: keep-all;
        background: var(--color-primary);
        border-radius: 4px;
      }
    }

    &-bottom {
      display: flex;
      align-items: center;
      // height: 20px;
      line-height: 20px;

      .logincode {
        font-size: 12px;
      }
    }
  }
}
</style>
